<?php 
class BrandControl extends CommonControl
{
    /**
     * 品牌首页展示
     * @return [type] [description]
     */
    public function index()
    {
        $db = M('g_brand')->all();
        $this->assign('brand',$db); 
        $this->display();
    }

    /**
     * 品牌添加
     */
    public function add()
    {
        if(IS_POST)
        {
            M('g_brand')->add();
            $this->success('添加品牌成功','index');
        }
        else
        {   
            $this->display();
        }
    }

    /**
     * 品牌删除
     * @return [type] [description]
     */
    public function del()
    {
        $bid = $_GET['bid'];
        M('g_brand')->where('bid='.$bid)->del();
        $this->success('删除成功','index');
    }

    public function edit()
    {
        if(IS_POST)
        {
            $bid = $_POST['bid'];
            M('g_brand')->where('bid='.$bid)->save();
            $this->success('编辑品牌成功','index');
        }
        else
        {   
            $bid = $_GET['bid'];
            $db = M('g_brand')->where('bid='.$bid)->find();
            $this->assign('brand',$db);
            $this->display();
        }
    }














}

 ?>